package com.kelvin.oocl;

import javax.jms.JMSException;

import com.kelvin.oocl.bookconsumer.BookConsumer;
import com.kelvin.oocl.dao.BookDao;
import com.kelvin.oocl.dao.impl.BookDaoImpl;
import com.kelvin.oocl.listener.MyMessageListener;
import com.kelvin.oocl.util.ConsumerFactory;

public class App {
	public static void main(String[] args) {
		BookConsumer consumer = null;
		try {
			BookDao bookDao = new BookDaoImpl();
			consumer = ConsumerFactory.newInstance().newBookConsumer("books");
			consumer.receive(new MyMessageListener(bookDao));
		} catch (JMSException e) {
			try {
				consumer.close();
			} catch (JMSException e1) {
				e1.printStackTrace();
			}
		}
	}
}
